package com.xzx.mr.order;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author xinzhixuan
 * @version V1.0
 * @date 2019/7/21 22:00
 */
public class OrderMapper extends Mapper<LongWritable, Text, Text, DoubleWritable> {
    private Text outKey = new Text();
    private DoubleWritable outValue = new DoubleWritable();

    // 0000001	Pdt_01	222.8
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] split = line.split("\t");
        outKey.set(split[0]);
        outValue.set(Double.parseDouble(split[2]));
        context.write(outKey, outValue);
    }
}
